package day03;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/**
 * Created by Administrator on 2023/7/1 0001.
 */
public class PointTester {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        Point[] points = new Point[n];

        System.out.println(Arrays.asList(points));
        for (int i = 0; i < n; i++) {
            points[i] = new Point();
            points[i].x = cin.nextInt();
            points[i].y = cin.nextInt();
        }
        Point o = new Point(cin.nextInt(), cin.nextInt());
        Arrays.sort(points, new Comparator<Point>() {
            @Override
            public int compare(Point p, Point q) {
                Double op = Math.hypot(o.x - p.x, o.y - p.y);
                Double oq = Math.hypot(o.x - q.x, o.y - q.y);
                int cmp = op.compareTo(oq);
                if (cmp != 0) return cmp;
                return p.compareTo(q);
            }
        });
        for (Point point : points) {
            System.out.println(point);
        }
    }
}
